home *** CD-ROM | disk | FTP | other *** search
- Path: xanth!indri!ames!oliveb!sun!rishathra!page
- From: page%rishathra@Sun.COM (Bob Page)
- Newsgroups: comp.sources.amiga
- Subject: v89i092: plplot - scientific plotting library, Part07/07
- Message-ID: <100944@sun.Eng.Sun.COM>
- Date: 25 Apr 89 05:47:57 GMT
- Sender: news@sun.Eng.Sun.COM
- Lines: 2206
- Approved: page@sun.com
-
- Submitted-by: amr@dukee.egr.duke.edu (Tony Richardson)
- Posting-number: Volume 89, Issue 92
- Archive-name: applications/plplot.7
-
- # This is a shell archive.
- # Remove anything above and including the cut line.
- # Then run the rest of the file through 'sh'.
- # Unpacked files will be owned by you and have default permissions.
- #----cut here-----cut here-----cut here-----cut here----#
- #!/bin/sh
- # shar: SHell ARchive
- # Run the following text through 'sh' to create:
- # plot3d.c
- # plplot.h
- # plpoi1.c
- # plpoin.c
- # plptex.c
- # plr135.c
- # plr45.c
- # plschr.c
- # plside3.c
- # plsmaj.c
- # plsmin.c
- # plssym.c
- # plstar.c
- # plstik.c
- # plstr.c
- # plstrl.c
- # plstyl.c
- # plsvpa.c
- # plsym.c
- # plsym1.c
- # plt3zz.c
- # pltext.c
- # plvpor.c
- # plvsta.c
- # plw3d.c
- # plwind.c
- # plxtik.c
- # plxybx.c
- # plxytx.c
- # plytik.c
- # plzbx.c
- # plztx.c
- # round.c
- # scratch
- # setphy.c
- # setpxl.c
- # setsub.c
- # stindex.c
- # strpos.c
- # tektronix.c
- # xform.c
- # This is archive 7 of a 7-part kit.
- # This archive created: Thu Apr 20 13:47:08 1989
- echo "extracting plot3d.c"
- sed 's/^X//' << \SHAR_EOF > plot3d.c
- X/* Plots a 3-d representation of the function z[x][y]. The x values */
- X/* are stored as x[0..nx-1], the y values as y[0..ny-1], and the */
- X/* z values are in the 2-d array z[][0..ly-1]. The integer "opt" */
- X/* specifies: */
- X/* opt = 1: Draw lines parallel to x-axis */
- X/* opt = 2: Draw lines parallel to y-axis */
- X/* opt = 3: Draw lines parallel to both axes */
- X
- X/* "work" is an integer work array of size at least 4*max(nx,ny) */
- X
- X#include "plplot.h"
- X#include <math.h>
- X
- Xvoid plot3d(x,y,z,work,ly,nx,ny,opt)
- Xint ly, nx, ny, opt;
- Xfloat x[],y[],*z;
- Xint work[];
- X{
- X int b;
- X float cxx, cxy, cyx, cyy, cyz;
- X
- X int init;
- X int i, ix, iy;
- X
- X int level;
- X glev(&level);
- X if (level < 3) fatal("Please set up window before calling PLOT3D");
- X
- X if (opt<1 || opt>3) fatal("Bad option in PLOT3D");
- X if (nx<=0 || ny<=0 || ly<ny) fatal("Bad array dimensions in PLOT3D.");
- X
- X/* Check that points in x and in y are strictly increasing */
- X
- X for (i=0; i<nx-1; i++)
- X if (x[i]>=x[i+1]) fatal("X(*) must be strictly increasing in PLOT3D");
- X
- X for (i=0; i<ny-1; i++)
- X if (y[i]>=y[i+1]) fatal("Y(*) must be strictly increasing in PLOT3D");
- X
- X b = 2*max(nx,ny)+1;
- X gw3wc(&cxx,&cxy,&cyx,&cyy,&cyz);
- X init = 1;
- X
- X if (cxx >= 0.0 && cxy <= 0.0) {
- X if (opt != 2) {
- X for (iy=2; iy<=ny; iy++) {
- X plt3zz(1,iy,1,-1,-opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X init = 0;
- X }
- X }
- X else {
- X plt3zz(1,ny,1,-1,-opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X init = 0;
- X }
- X if (opt != 1)
- X for (ix=1; ix<=nx-1; ix++)
- X plt3zz(ix,ny,1,-1,opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X else
- X plt3zz(1,ny,1,-1,opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X }
- X else if (cxx <= 0.0 && cxy <= 0.0) {
- X if (opt != 1) {
- X for (ix=2; ix<=nx; ix++) {
- X plt3zz(ix,ny,-1,-1,opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X init = 0;
- X }
- X }
- X else {
- X plt3zz(nx,ny,-1,-1,opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X init = 0;
- X }
- X if (opt != 2)
- X for (iy=ny; iy>=2; iy--)
- X plt3zz(nx,iy,-1,-1,-opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X else
- X plt3zz(nx,ny,-1,-1,-opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X }
- X else if (cxx <= 0.0 && cxy >= 0.0) {
- X if (opt != 2) {
- X for (iy=ny-1; iy>=1; iy--) {
- X plt3zz(nx,iy,-1,1,-opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X init = 0;
- X }
- X }
- X else {
- X plt3zz(nx,1,-1,1,-opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X init = 0;
- X }
- X if (opt != 1)
- X for (ix=nx; ix>=2; ix--)
- X plt3zz(ix,1,-1,1,opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X else
- X plt3zz(nx,1,-1,1,opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X }
- X else if (cxx >= 0.0 && cxy >= 0.0) {
- X if (opt != 1) {
- X for (ix=nx-1; ix>=1; ix--) {
- X plt3zz(ix,1,1,1,opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X init = 0;
- X }
- X }
- X else {
- X plt3zz(1,1,1,1,opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X init = 0;
- X }
- X if (opt != 2)
- X for (iy=1; iy<=ny-1; iy++)
- X plt3zz(1,iy,1,1,-opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X else
- X plt3zz(1,1,1,1,-opt,init,x,y,z,ly,nx,ny,&work[0],&work[b-1]);
- X }
- X}
- SHAR_EOF
- echo "extracting plplot.h"
- sed 's/^X//' << \SHAR_EOF > plplot.h
- X/* This file contains all of the type declarations for the functions *
- X * in the plplot library. This file should be included in all user *
- X * routines that make use of that library. */
- X
- X/* All of the void type declarations are made first. */
- Xvoid pladv();
- Xvoid plbeg();
- Xvoid plbin();
- Xvoid plbox();
- Xvoid plccal();
- Xvoid plclr();
- Xvoid plcntr();
- Xvoid plcol();
- Xvoid plcont();
- Xvoid pldeco();
- Xvoid pldtik();
- Xvoid plend();
- Xvoid plenv();
- Xvoid plerrx();
- Xvoid plerry();
- Xvoid plerx1();
- Xvoid plery1();
- Xvoid plfont();
- Xvoid plform();
- Xvoid plgra();
- Xvoid plgspa();
- Xvoid plhist();
- Xvoid plhrsh();
- Xvoid pljoin();
- Xvoid pllab();
- Xvoid pllclp();
- Xvoid plline();
- Xvoid plmtex();
- Xvoid plnxtv();
- Xvoid plpoi1();
- Xvoid plpoin();
- Xvoid plptex();
- Xvoid plr135();
- Xvoid plr45();
- Xvoid plschr();
- Xvoid plsmaj();
- Xvoid plsmin();
- Xvoid plssym();
- Xvoid plstar();
- Xvoid plstik();
- Xvoid plstr();
- Xvoid plstyl();
- Xvoid plsvpa();
- Xvoid plsym();
- Xvoid plsym1();
- Xvoid pltext();
- Xvoid plupd();
- Xvoid plvpor();
- Xvoid plvsta();
- Xvoid plwind();
- Xvoid plxtik();
- Xvoid plxybx();
- Xvoid plxytx();
- Xvoid plytik();
- Xvoid plzbx();
- Xvoid plztx();
- X
- X/* 3-D routine types*/
- Xvoid pl3cut();
- Xvoid plbox3();
- Xvoid plgrid3();
- Xvoid plot3d();
- Xvoid plside3();
- Xvoid plt3zz();
- Xvoid plw3d();
- X
- X/* The novice plplot user will not need to call the following functions */
- Xvoid fatal();
- Xvoid genlin();
- Xvoid movphy();
- Xvoid draphy();
- Xvoid movwor();
- Xvoid drawor();
- Xvoid setphy();
- Xvoid setpxl();
- Xvoid setsub();
- Xvoid xform();
- Xvoid glev();
- Xvoid slev();
- Xvoid gbase();
- Xvoid sbase();
- Xvoid gnms();
- Xvoid snms();
- Xvoid gdev();
- Xvoid sdev();
- Xvoid gcurr();
- Xvoid scurr();
- Xvoid gdom();
- Xvoid sdom();
- Xvoid grange();
- Xvoid srange();
- Xvoid gw3wc();
- Xvoid sw3wc();
- Xvoid gvpp();
- Xvoid svpp();
- Xvoid gspp();
- Xvoid sspp();
- Xvoid gclp();
- Xvoid sclp();
- Xvoid gphy();
- Xvoid sphy();
- Xvoid gsub();
- Xvoid ssub();
- Xvoid gumpix();
- Xvoid sumpix();
- Xvoid gatt();
- Xvoid satt();
- Xvoid gspd();
- Xvoid sspd();
- Xvoid gvpd();
- Xvoid svpd();
- Xvoid gvpw();
- Xvoid svpw();
- Xvoid gpixmm();
- Xvoid spixmm();
- Xvoid gwp();
- Xvoid swm();
- Xvoid gwm();
- Xvoid swp();
- Xvoid gdp();
- Xvoid sdp();
- Xvoid gmp();
- Xvoid smp();
- Xvoid gchr();
- Xvoid schr();
- Xvoid gsym();
- Xvoid ssym();
- Xvoid gmaj();
- Xvoid smaj();
- Xvoid gmin();
- Xvoid smin();
- X
- X/* Functions that return floats */
- Xfloat plstrl();
- Xfloat dcmmx();
- Xfloat dcmmy();
- Xfloat dcscx();
- Xfloat dcscy();
- Xfloat mmdcx();
- Xfloat mmdcy();
- Xfloat scdcx();
- Xfloat scdcy();
- Xfloat wcmmx();
- Xfloat wcmmy();
- Xfloat w3wcx();
- Xfloat w3wcy();
- X
- X/* Functions returning ints */
- Xint plabv();
- Xint plcvec();
- Xint dcpcx();
- Xint dcpcy();
- Xint mmpcx();
- Xint mmpcy();
- Xint round();
- Xint stindex();
- Xint strpos();
- Xint wcpcx();
- Xint wcpcy();
- X
- X/* Device independent routines */
- Xvoid grbeg();
- Xvoid grclr();
- Xvoid grcol();
- Xvoid grinit();
- Xvoid grgra();
- Xvoid grline();
- Xvoid grtext();
- Xvoid grtidy();
- X
- X/* Declarations for any new device drivers should be added to the list *
- X * below. These routines are called only in the file plstar.c (except *
- X * for beepw() which is also called by ???) */
- Xvoid amiini();
- Xvoid amitex();
- Xvoid amigra();
- Xvoid amicol();
- Xvoid amiclr();
- Xvoid amilin();
- Xvoid amitid();
- Xvoid beepw();
- X
- Xvoid tekini();
- Xvoid tektex();
- Xvoid tekgra();
- Xvoid tekclr();
- Xvoid tekcol();
- Xvoid teklin();
- Xvoid tektid();
- X
- Xvoid impini();
- Xvoid imptex();
- Xvoid impgra();
- Xvoid impclr();
- Xvoid impcol();
- Xvoid implin();
- Xvoid imptid();
- X
- Xvoid jetini();
- Xvoid jettex();
- Xvoid jetgra();
- Xvoid jetclr();
- Xvoid jetcol();
- Xvoid jetlin();
- Xvoid jettid();
- SHAR_EOF
- echo "extracting plpoi1.c"
- sed 's/^X//' << \SHAR_EOF > plpoi1.c
- X#include "plplot.h"
- X
- Xextern short int *hersh[];
- X
- Xvoid plpoi1(x,y,code)
- Xfloat x,y;
- Xint code;
- X{
- X int sym, font, col;
- X
- X/* Initialize parameters. */
- X
- X gatt(&font,&col);
- X sym = *(hersh[font-1]+code);
- X plhrsh(sym,wcpcx(x),wcpcy(y));
- X}
- SHAR_EOF
- echo "extracting plpoin.c"
- sed 's/^X//' << \SHAR_EOF > plpoin.c
- X/* Plots single precision array y against x for n points using */
- X/* ASCII code "code" */
- X
- X#include "plplot.h"
- X
- Xvoid plpoin(n,x,y,code)
- Xint n, code;
- Xfloat x[],y[];
- X{
- X int i;
- X
- X int level;
- X glev(&level);
- X if (level < 3) fatal("Please set up window before calling PLPOIN.");
- X if (code < 0 || code > 127) fatal("Invalid code in PLPOIN.");
- X
- X for(i=0; i<n; i++)
- X plpoi1(x[i],y[i],code);
- X}
- SHAR_EOF
- echo "extracting plptex.c"
- sed 's/^X//' << \SHAR_EOF > plptex.c
- X/* Prints out "text" at world cooordinate (x,y). The text may be */
- X/* at any angle "angle" relative to the horizontal. The parameter */
- X/* "just" adjusts the horizontal justification of the string: */
- X/* just = 0.0 => left hand edge of string is at (x,y) */
- X/* just = 1.0 => right hand edge of string is at (x,y) */
- X/* just = 0.5 => centre of string is at (x,y) etc. */
- X/* N.B. Centreline of the string passes through (x,y) */
- X
- X#include "plplot.h"
- X#include <math.h>
- X
- Xvoid plptex(x,y,dx,dy,just,text)
- Xfloat x,y,dx,dy,just;
- Xchar *text;
- X{
- X int refx, refy;
- X float shift, cc, ss;
- X float xform[4],diag;
- X float xscl, xoff, yscl, yoff;
- X
- X int level;
- X glev(&level);
- X if (level < 3) fatal("Please set up window before calling PLPTEX.");
- X
- X gwm(&xscl,&xoff,&yscl,&yoff);
- X cc = xscl * dx;
- X ss = yscl * dy;
- X diag = sqrt(cc*cc + ss*ss);
- X cc = cc/diag;
- X ss = ss/diag;
- X
- X gmp(&xscl,&xoff,&yscl,&yoff);
- X shift = 0.0;
- X
- X xform[0] = cc;
- X xform[1] = -ss;
- X xform[2] = ss;
- X xform[3] = cc;
- X
- X if (just != 0.0) shift = plstrl(text) * just;
- X refx = wcpcx(x) - shift * cc * xscl;
- X refy = wcpcy(y) - shift * ss * yscl;
- X plstr(0,xform,refx,refy,text);
- X}
- SHAR_EOF
- echo "extracting plr135.c"
- sed 's/^X//' << \SHAR_EOF > plr135.c
- X#include "plplot.h"
- X
- Xvoid plr135(ix,iy,isens)
- Xint *ix, *iy, isens;
- X{
- X *ix = -*ix;
- X *iy = -*iy;
- X plr45(ix,iy,isens);
- X}
- SHAR_EOF
- echo "extracting plr45.c"
- sed 's/^X//' << \SHAR_EOF > plr45.c
- X#include "plplot.h"
- X#include <math.h>
- X
- Xvoid plr45(ix,iy,isens)
- Xint *ix, *iy, isens;
- X{
- X int ixx, iyy;
- X
- X ixx = *ix-isens*(*iy);
- X iyy = *ix * isens + *iy;
- X *ix = ixx/max(1,abs(ixx));
- X *iy = iyy/max(1,abs(iyy));
- X}
- SHAR_EOF
- echo "extracting plschr.c"
- sed 's/^X//' << \SHAR_EOF > plschr.c
- X#include "plplot.h"
- X
- Xvoid plschr(def,scale)
- Xfloat def,scale;
- X{
- X float defalt, ht;
- X
- X if (def != 0.0)
- X schr(def,scale*def);
- X else {
- X gchr(&defalt,&ht);
- X schr(defalt,scale*defalt);
- X }
- X}
- SHAR_EOF
- echo "extracting plside3.c"
- sed 's/^X//' << \SHAR_EOF > plside3.c
- X/* This routine draws sides around the front of the 3d plot so that */
- X/* it does not appear to float */
- X
- X#include "plplot.h"
- X
- Xvoid plside3(x,y,z,nx,ny,ly,opt)
- Xint nx, ny, ly, opt;
- Xfloat *x, *y, *z;
- X{
- X int i;
- X float cxx, cxy, cyx, cyy, cyz;
- X float xmin, ymin, zmin, xmax, ymax, zmax, zscale;
- X float tx, ty, ux, uy;
- X
- X gw3wc(&cxx,&cxy,&cyx,&cyy,&cyz);
- X gdom(&xmin,&xmax,&ymin,&ymax);
- X grange(&zscale,&zmin,&zmax);
- X
- X if (cxx >= 0.0 && cxy <= 0.0) {
- X /* Get x, y coordinates of legs and plot */
- X if (opt != 1) {
- X for (i=0; i<nx; i++) {
- X tx = w3wcx(*(x+i),*y,zmin);
- X ty = w3wcy(*(x+i),*y,zmin);
- X ux = w3wcx(*(x+i),*y,*(z+i*ly));
- X uy = w3wcy(*(x+i),*y,*(z+i*ly));
- X pljoin(tx,ty,ux,uy);
- X }
- X }
- X
- X if (opt != 2) {
- X for (i=0; i<ny; i++) {
- X tx = w3wcx(*x,*(y+i),zmin);
- X ty = w3wcy(*x,*(y+i),zmin);
- X ux = w3wcx(*x,*(y+i),*(z+i));
- X uy = w3wcy(*x,*(y+i),*(z+i));
- X pljoin(tx,ty,ux,uy);
- X }
- X }
- X }
- X else if(cxx <= 0.0 && cxy <= 0.0) {
- X if (opt != 1 ) {
- X for (i=0; i<nx; i++) {
- X tx = w3wcx(*(x+i),*(y+ny-1),zmin);
- X ty = w3wcy(*(x+i),*(y+ny-1),zmin);
- X ux = w3wcx(*(x+i),*(y+ny-1),*(z+i*ly+ny-1));
- X uy = w3wcy(*(x+i),*(y+ny-1),*(z+i*ly+ny-1));
- X pljoin(tx,ty,ux,uy);
- X }
- X }
- X
- X if (opt != 2) {
- X for (i=0; i<ny; i++) {
- X tx = w3wcx(*x,*(y+i),zmin);
- X ty = w3wcy(*x,*(y+i),zmin);
- X ux = w3wcx(*x,*(y+i),*(z+i));
- X uy = w3wcy(*x,*(y+i),*(z+i));
- X pljoin(tx,ty,ux,uy);
- X }
- X }
- X }
- X else if(cxx <= 0.0 && cxy >= 0.0) {
- X if (opt != 1) {
- X for (i=0; i<nx; i++) {
- X tx = w3wcx(*(x+i),*(y+ny-1),zmin);
- X ty = w3wcy(*(x+i),*(y+ny-1),zmin);
- X ux = w3wcx(*(x+i),*(y+ny-1),*(z+i*ly+ny-1));
- X uy = w3wcy(*(x+i),*(y+ny-1),*(z+i*ly+ny-1));
- X pljoin(tx,ty,ux,uy);
- X }
- X }
- X
- X if (opt != 2) {
- X for (i=0; i<ny; i++) {
- X tx = w3wcx(*(x+nx-1),*(y+i),zmin);
- X ty = w3wcy(*(x+nx-1),*(y+i),zmin);
- X ux = w3wcx(*(x+nx-1),*(y+i),*(z+(nx-1)*ly+i));
- X uy = w3wcy(*(x+nx-1),*(y+i),*(z+(nx-1)*ly+i));
- X pljoin(tx,ty,ux,uy);
- X }
- X }
- X }
- X else if(cxx >= 0.0 && cxy >= 0.0) {
- X if (opt != 1) {
- X for (i=0; i<nx; i++) {
- X tx = w3wcx(*(x+i),*y,zmin);
- X ty = w3wcy(*(x+i),*y,zmin);
- X ux = w3wcx(*(x+i),*y,*(z+i*ly));
- X uy = w3wcy(*(x+i),*y,*(z+i*ly));
- X pljoin(tx,ty,ux,uy);
- X }
- X }
- X
- X if (opt != 2) {
- X for (i=0; i<ny; i++) {
- X tx = w3wcx(*(x+nx-1),*(y+i),zmin);
- X ty = w3wcy(*(x+nx-1),*(y+i),zmin);
- X ux = w3wcx(*(x+nx-1),*(y+i),*(z+(nx-1)*ly+i));
- X uy = w3wcy(*(x+nx-1),*(y+i),*(z+(nx-1)*ly+i));
- X pljoin(tx,ty,ux,uy);
- X }
- X }
- X }
- X}
- SHAR_EOF
- echo "extracting plsmaj.c"
- sed 's/^X//' << \SHAR_EOF > plsmaj.c
- X#include "plplot.h"
- X
- Xvoid plsmaj(def,scale)
- Xfloat def,scale;
- X{
- X float defalt, ht;
- X
- X if (def != 0.0)
- X smaj(def,scale*def);
- X else {
- X gmaj(&defalt,&ht);
- X smaj(defalt,scale*defalt);
- X }
- X}
- SHAR_EOF
- echo "extracting plsmin.c"
- sed 's/^X//' << \SHAR_EOF > plsmin.c
- X#include "plplot.h"
- X
- Xvoid plsmin(def,scale)
- Xfloat def, scale;
- X{
- X float defalt, ht;
- X if (def != 0.0)
- X smin(def,scale*def);
- X else {
- X gmin(&defalt,&ht);
- X smin(defalt,scale*defalt);
- X }
- X}
- SHAR_EOF
- echo "extracting plssym.c"
- sed 's/^X//' << \SHAR_EOF > plssym.c
- X#include "plplot.h"
- X
- Xvoid plssym(def,scale)
- Xfloat def,scale;
- X{
- X float defalt,ht;
- X
- X if (def != 0.0)
- X ssym(def,scale*def);
- X else {
- X gsym(&defalt,&ht);
- X ssym(defalt,scale*defalt);
- X }
- X}
- SHAR_EOF
- echo "extracting plstar.c"
- sed 's/^X//' << \SHAR_EOF > plstar.c
- X#include "plplot.h"
- X#include "declare.h"
- X#include <stdio.h>
- X
- X/* Asks for number of plotting device, and call plbeg to divide the */
- X/* page into nx by ny subpages */
- X
- Xstatic int mk=0, sp=0;
- X
- Xvoid plstar(nx,ny)
- Xint nx, ny;
- X{
- X int dev,lev;
- X
- X glev(&lev);
- X if (lev != 0) plend();
- X
- X printf("\nPlotting Options:");
- X printf("\n < 1> Amiga");
- X printf("\n < 2> LaserJet II file (landscape)");
- X printf("\n < 3> LaserJet II file (portrait)");
- X printf("\n < 4> imPRESS file (landscape)");
- X printf("\n < 5> imPRESS file (portrait)");
- X printf("\n < 6> Tektronix file (landscape)");
- X printf("\n < 7> Tektronix file (portrait)");
- X printf("\n");
- X printf("\nEnter device number: ");
- X scanf("%d",&dev);
- X while(getchar() != '\n') /* Read all of line including new line char */
- X ;
- X plbeg(dev,nx,ny);
- X}
- X
- X/* Initializes the graphics device "dev" */
- Xvoid grbeg(dev)
- Xint dev;
- X{
- X int termin, phyxmi, phyxma, phyymi, phyyma;
- X void grinit(), grclr(), grcol(), grgra();
- X
- X /* Set up device specific stuff */
- X
- X /* Use setpxl to set the device dots per mm in the x and y directions */
- X /* dpmmx = dots/mm in x direction (float) */
- X /* dpmmy = dots/mm in y direction (float) */
- X /* setpxl(dpmmx,dpmmy); */
- X
- X /* PLPLOT assumes that the plot origin is in the lower left corner */
- X /* with y increasing upward and x increasing to the right */
- X /* Use setphy to specify how PLPLOT should translate plotting coords */
- X /* to device coords */
- X /* xmindev = minimum x device coordinate (int) */
- X /* xmaxdev = maximum x device coordinate (int) */
- X /* ymindev = minimum y device coordinate (int) */
- X /* ymaxdev = maximum y device coordinate (int) */
- X /* setphy(xmindev,xmaxdev,ymindev,ymaxdev); */
- X
- X if (dev == 1) {
- X setpxl(2.52,2.25);
- X setphy(0,639,0,399);
- X termin = 1;
- X }
- X else if (dev == 2) {
- X setpxl(5.905,5.905); /* 150 dpi mode */
- X termin = 0;
- X setphy(0,1409,0,1103);
- X }
- X else if (dev == 3) {
- X setpxl(5.905,5.905); /* 150 dpi mode */
- X termin = 0;
- X setphy(0,1103,1409,0);
- X }
- X else if (dev == 4) {
- X setpxl(11.81,11.81); /* 300 dpi */
- X termin = 0;
- X setphy(0,2999,0,2249);
- X }
- X else if (dev == 5) {
- X setpxl(11.81,11.81); /* 300 dpi */
- X termin = 0;
- X setphy(2249,0,0,2999);
- X }
- X else if (dev == 6 ) {
- X setpxl(4.771,4.653);
- X termin = 0;
- X setphy(0,1023,0,779);
- X }
- X else if (dev == 7) {
- X setpxl(4.653,4.771);
- X termin = 0;
- X setphy(779,0,0,1023);
- X }
- X else {
- X printf("\nUnknown output device\n");
- X exit(1);
- X }
- X
- X sdev(dev,termin,0);
- X grinit();
- X
- X /* Set default sizes, fonts, and colors */
- X plschr(4.0,1.0);
- X plssym(4.0,1.0);
- X plsmaj(3.0,1.0);
- X plsmin(1.5,1.0);
- X satt(1,1);
- X
- X /* Switch to graphics mode and clear screen */
- X grgra();
- X grclr();
- X grcol();
- X plstyl(0,&mk,&sp);
- X
- X gphy(&phyxmi,&phyxma,&phyymi,&phyyma);
- X sclp(phyxmi,phyxma,phyymi,phyyma);
- X}
- X
- X/* Clears the graphics screen */
- Xvoid grclr()
- X{
- X if (device == 1)
- X amiclr();
- X else if (device == 2 || device == 3)
- X jetclr();
- X else if (device == 4 || device == 5)
- X impclr();
- X else if (device == 6 || device == 7)
- X tekclr();
- X}
- X
- X/* Sets up the line colour to value in global variable "colour" */
- Xvoid grcol()
- X{
- X if (device == 1)
- X amicol(colour);
- X}
- X
- X/* Initializes the graphics device */
- Xvoid grinit()
- X{
- X if (device == 1)
- X amiini();
- X else if (device == 2 || device == 3)
- X jetini();
- X else if (device == 4 || device == 5)
- X impini();
- X else if (device == 6 || device == 7)
- X tekini();
- X}
- X
- X/* Switches to graphics mode */
- Xvoid grgra()
- X{
- X if (device == 1)
- X amigra();
- X else if (device == 2 || device == 3)
- X jetgra();
- X else if (device == 4 || device == 5)
- X impgra();
- X else if (device == 6 || device == 7)
- X tekgra();
- X
- X graphx = 1;
- X}
- X
- X/* Draws a line from (x1,x2) to (x2,y2), used by genlin() */
- X/* Notice how x and y are swapped to switch from the default */
- X/* orientation */
- Xvoid grline(x1,y1,x2,y2)
- Xint x1,y1,x2,y2;
- X{
- X if (device == 1)
- X amilin(x1,y1,x2,y2);
- X else if (device == 2)
- X jetlin(y1,x1,y2,x2);
- X else if (device == 3)
- X jetlin(x1,y1,x2,y2);
- X else if (device == 4)
- X implin(x1,y1,x2,y2);
- X else if (device == 5)
- X implin(y1,x1,y2,x2);
- X else if (device == 6)
- X teklin(x1,y1,x2,y2);
- X else if (device == 7)
- X teklin(y1,x1,y2,x2);
- X}
- X
- X/* Switches to text mode */
- Xvoid grtext()
- X{
- X if (device == 1)
- X amitex();
- X else if (device == 2 || device == 3)
- X jettex();
- X else if (device == 4 || device == 5)
- X imptex();
- X else if (device == 6 || device == 7)
- X tektex();
- X
- X graphx = 0;
- X}
- X
- X/* Called by plend to tidy up graphics device */
- Xvoid grtidy()
- X{
- X if (device == 1)
- X amitid();
- X else if (device == 2 || device == 3)
- X jettid();
- X else if (device == 4 || device == 5)
- X imptid();
- X else if (device == 6 || device == 7)
- X tektid();
- X}
- SHAR_EOF
- echo "extracting plstik.c"
- sed 's/^X//' << \SHAR_EOF > plstik.c
- X/* Draws a slanting tick at position (mx,my) (measured in mm) of */
- X/* vector length (dx,dy) */
- X
- X#include "plplot.h"
- X
- Xvoid plstik(mx,my,dx,dy)
- Xfloat mx, my, dx, dy;
- X{
- X draphy(mmpcx(mx),mmpcy(my));
- X draphy(mmpcx(mx+dx),mmpcy(my+dy));
- X draphy(mmpcx(mx),mmpcy(my));
- X}
- SHAR_EOF
- echo "extracting plstr.c"
- sed 's/^X//' << \SHAR_EOF > plstr.c
- X/* Prints out a "string" at reference position with physical */
- X/* coordinates (refx,refy). The coordinates of the vectors defining */
- X/* the string are passed through the linear mapping defined by the */
- X/* 2 x 2 matrix xform() before being plotted. */
- X/* The reference position is at the left-hand edge of the string. If */
- X/* base = 1, it is aligned with the baseline of the string. If */
- X/* base = 0, it is aligned with the centre of the character box. */
- X
- X/* Note, all calculations are done in terms of millimetres. These */
- X/* are scaled as necessary before plotting the string on the page */
- X
- X#include "plplot.h"
- X#include <math.h>
- X
- Xvoid plstr(base,xform,refx,refy,string)
- Xint base, refx, refy;
- Xchar *string;
- Xfloat xform[4];
- X{
- X int symbol[256];
- X short int xygrid[300];
- X int ch, cx, cy, i, k, length, level, penup;
- X int xbase, ybase, ydisp, lx, ly, style;
- X int oline, uline;
- X float width, xorg, yorg, x, y, def, ht, dscale, scale;
- X float xscl, xoff, yscl, yoff;
- X
- X width = 0.0;
- X oline = 0;
- X uline = 0;
- X
- X gchr(&def,&ht);
- X dscale = 0.05*ht;
- X scale = dscale;
- X gmp(&xscl,&xoff,&yscl,&yoff);
- X
- X/* Line style must be continuous */
- X
- X gnms(&style);
- X snms(0);
- X
- X pldeco(symbol,&length,string);
- X xorg = 0.0;
- X yorg = 0.0;
- X level = 0;
- X
- X for (i=0; i<length; i++) {
- X ch = symbol[i];
- X if (ch == -1) {
- X level = level + 1;
- X yorg = yorg + 16.0 * scale;
- X scale = dscale * pow(0.75,(double)abs(level));
- X }
- X else if (ch == -2) {
- X level = level - 1;
- X scale = dscale * pow(0.75,(double)abs(level));
- X yorg = yorg - 16.0 * scale;
- X }
- X else if (ch == -3)
- X xorg = xorg - width * scale;
- X else if (ch == -4)
- X oline = !oline;
- X else if (ch == -5)
- X uline = !uline;
- X else {
- X if (plcvec(ch,xygrid)) {
- X xbase = xygrid[3];
- X width = xygrid[4] - xbase;
- X if (base == 0) {
- X ybase = 0;
- X ydisp = xygrid[1];
- X }
- X else {
- X ybase = xygrid[1];
- X ydisp = 0;
- X }
- X k = 5;
- X penup = 1;
- Xlab2:
- X cx = xygrid[k];
- X k = k+1;
- X cy = xygrid[k];
- X k = k+1;
- X if (cx == -64 && cy == -64) goto lab3;
- X if (cx == -64 && cy == 0)
- X penup = 1;
- X else {
- X x = xorg + (cx - xbase) * scale;
- X y = yorg + (cy - ybase) * scale;
- X lx = refx + round(xscl*(xform[0]*x + xform[1]*y));
- X ly = refy + round(yscl*(xform[2]*x + xform[3]*y));
- X if (penup != 0) {
- X movphy(lx,ly);
- X penup = 0;
- X }
- X else
- X draphy(lx,ly);
- X }
- X goto lab2;
- Xlab3:
- X if (oline) {
- X x = xorg;
- X y = yorg + (30+ydisp)*scale;
- X lx = refx + round(xscl*(xform[0]*x + xform[1]*y));
- X ly = refy + round(yscl*(xform[2]*x + xform[3]*y));
- X movphy(lx,ly);
- X x = xorg + width*scale;
- X lx = refx + round(xscl*(xform[0]*x + xform[1]*y));
- X ly = refy + round(yscl*(xform[2]*x + xform[3]*y));
- X draphy(lx,ly);
- X }
- X if (uline) {
- X x = xorg;
- X y = yorg + (-5+ydisp)*scale;
- X lx = refx + round(xscl*(xform[0]*x + xform[1]*y));
- X ly = refy + round(yscl*(xform[2]*x + xform[3]*y));
- X movphy(lx,ly);
- X x = xorg + width*scale;
- X lx = refx + round(xscl*(xform[0]*x + xform[1]*y));
- X ly = refy + round(yscl*(xform[2]*x + xform[3]*y));
- X draphy(lx,ly);
- X }
- X xorg = xorg + width*scale;
- X }
- X }
- X }
- X snms(style);
- X}
- X
- SHAR_EOF
- echo "extracting plstrl.c"
- sed 's/^X//' << \SHAR_EOF > plstrl.c
- X/* Computes the length of a string in mm, including escape sequences */
- X
- X#include "plplot.h"
- X#include <math.h>
- X
- Xfloat plstrl(string)
- Xchar *string;
- X{
- X int symbol[256];
- X short int xygrid[300];
- X int ch, i, length, level;
- X float width, xorg, dscale, scale, def, ht;
- X float xscl, xoff, yscl, yoff;
- X
- X width = 0.0;
- X gchr(&def,&ht);
- X dscale = 0.05*ht;
- X scale = dscale;
- X gmp(&xscl,&xoff,&yscl,&yoff);
- X
- X pldeco(symbol,&length,string);
- X xorg = 0.0;
- X level = 0;
- X
- X for (i=0; i<length; i++) {
- X ch = symbol[i];
- X if (ch == -1) {
- X level = level + 1;
- X scale = dscale * pow(0.75,(double)abs(level));
- X }
- X else if (ch == -2) {
- X level = level - 1;
- X scale = dscale * pow(0.75,(double)abs(level));
- X }
- X else if (ch == -3)
- X xorg = xorg - width * scale;
- X else if (ch == -4 || ch == -5)
- X ;
- X else {
- X if (plcvec(ch,xygrid)) {
- X width = xygrid[4] - xygrid[3];
- X xorg = xorg + width*scale;
- X }
- X }
- X }
- X return(xorg);
- X}
- SHAR_EOF
- echo "extracting plstyl.c"
- sed 's/^X//' << \SHAR_EOF > plstyl.c
- X/* Set up a new line style of "nels" elements, with mark and space */
- X/* lengths given by arrays "mk" and "sp". */
- X
- X#include "plplot.h"
- X#include "declare.h"
- X
- Xvoid plstyl(nels,mk,sp)
- Xint nels,mk[],sp[];
- X{
- X int i;
- X
- X if ((nels < 0) || (nels > 10)) {
- X fatal("Broken lines cannot have <0 or >10 elements");
- X }
- X
- X nms = nels;
- X for (i=0; i<nels; i++) {
- X mark[i] = mk[i];
- X space[i] = sp[i];
- X if ((mk[i] < 0) || (sp[i] < 0))
- X fatal("Mark and space lengths must be > 0 in PLSTYL");
- X }
- X
- X curel = 0;
- X pendn = 1;
- X timecnt = 0;
- X alarm = mark[curel];
- X}
- X
- X/* Updates line style variables, called whenever alarm goes off */
- X
- Xvoid plupd()
- X{
- X while ( timecnt >= alarm ) {
- X if (pendn != 0) {
- X pendn = 0;
- X timecnt = timecnt - alarm;
- X alarm = space[curel];
- X }
- X else {
- X pendn = 1;
- X timecnt = timecnt - alarm;
- X curel = curel + 1;
- X if (curel >= nms) curel = 0;
- X alarm = mark[curel];
- X }
- X }
- X}
- X
- X
- SHAR_EOF
- echo "extracting plsvpa.c"
- sed 's/^X//' << \SHAR_EOF > plsvpa.c
- X/* Sets the edges of the viewport to the specified absolute */
- X/* coordinates (mm), measured with respect to the current subpage */
- X/* boundaries */
- X
- X#include "plplot.h"
- X
- Xvoid plsvpa(xmin,xmax,ymin,ymax)
- Xfloat xmin, xmax, ymin, ymax;
- X{
- X
- X int nx, ny, cs;
- X float sxmin, symin;
- X float spdxmi, spdxma, spdymi, spdyma;
- X float vpdxmi, vpdxma, vpdymi, vpdyma;
- X
- X int level;
- X
- X glev(&level);
- X if (level<1) fatal("Please call PLSTAR before calling PLSVPA.");
- X if((xmin>=xmax)||(ymin>=ymax)||(xmin<0.)||(ymin<0.))
- X fatal("Invalid limits in PLSVPA.");
- X
- X gsub(&nx,&ny,&cs);
- X if ((cs<=0) || (cs>(nx*ny)))
- X fatal("Please call PLADV or PLENV to go to a subpage.");
- X
- X gspd(&spdxmi,&spdxma,&spdymi,&spdyma);
- X sxmin = dcmmx(spdxmi);
- X symin = dcmmy(spdymi);
- X
- X vpdxmi = mmdcx(sxmin+xmin);
- X vpdxma = mmdcx(sxmin+xmax);
- X vpdymi = mmdcy(symin+ymin);
- X vpdyma = mmdcy(symin+ymax);
- X
- X svpd(vpdxmi,vpdxma,vpdymi,vpdyma);
- X svpp(dcpcx(vpdxmi),dcpcx(vpdxma),dcpcy(vpdymi),dcpcy(vpdyma));
- X sclp(dcpcx(vpdxmi),dcpcx(vpdxma),dcpcy(vpdymi),dcpcy(vpdyma));
- X slev(2);
- X}
- X
- SHAR_EOF
- echo "extracting plsym.c"
- sed 's/^X//' << \SHAR_EOF > plsym.c
- X/* Plots single precision array y against x for n points using */
- X/* Hershey symbol "code" */
- X
- X#include "plplot.h"
- X
- Xvoid plsym(n,x,y,code)
- Xint n, code;
- Xfloat x[],y[];
- X{
- X int i;
- X
- X int level;
- X glev(&level);
- X if (level < 3) fatal("Please set up window before calling PLSYM.");
- X if (code < 0) fatal("Invalid code in PLSYM.");
- X
- X for (i=0; i<n; i++)
- X plsym1(x[i],y[i],code);
- X}
- SHAR_EOF
- echo "extracting plsym1.c"
- sed 's/^X//' << \SHAR_EOF > plsym1.c
- X#include "plplot.h"
- X
- Xvoid plsym1(x,y,code)
- Xfloat x,y;
- Xint code;
- X{
- X plhrsh(code,wcpcx(x),wcpcy(y));
- X}
- SHAR_EOF
- echo "extracting plt3zz.c"
- sed 's/^X//' << \SHAR_EOF > plt3zz.c
- X/* Draws the next zig-zag line for a 3-d plot. The data is stored in */
- X/* array z(*,ly) as a function of x() and y(). The subarray */
- X/* z(1:nx,1:ny) is plotted out, starting at index (xstar0,ystar0). */
- X/* Depending on the state of "flg0", the sequence of data points */
- X/* sent to plnxtv is altered so as to allow cross-hatch plotting, */
- X/* or plotting parallel to either the x-axis or the y-axis. */
- X
- X#include "plplot.h"
- X
- Xvoid plt3zz(xstar0,ystar0,dx,dy,flg0,init,x,y,z,ly,nx,ny,u,v)
- Xint xstar0, ystar0, dx, dy, flg0, ly, nx, ny, init;
- Xfloat x[], y[], *z;
- Xint u[], v[];
- X{
- X int flag;
- X int n;
- X int xstart, ystart;
- X
- X n = 0;
- X xstart = xstar0;
- X ystart = ystar0;
- X flag = flg0;
- X
- Xlab1:
- X if (1 <= xstart && xstart <= nx && 1 <= ystart && ystart <= ny) {
- X u[n] = wcpcx(w3wcx(x[xstart-1],y[ystart-1],
- X *(z+(xstart-1)*ly+(ystart-1))));
- X v[n] = wcpcy(w3wcy(x[xstart-1],y[ystart-1],
- X *(z+(xstart-1)*ly+(ystart-1))));
- X if (flag == -3) {
- X ystart = ystart + dy;
- X flag = -flag;
- X }
- X else if (flag == -2)
- X ystart = ystart + dy;
- X else if (flag == -1) {
- X ystart = ystart + dy;
- X flag = 1;
- X }
- X else if (flag == 1)
- X xstart = xstart + dx;
- X else if (flag == 2) {
- X xstart = xstart + dx;
- X flag = -2;
- X }
- X else if (flag == 3) {
- X xstart = xstart + dx;
- X flag = -flag;
- X }
- X n = n+1;
- X goto lab1;
- X }
- X
- X if (flag == 1 || flag == -2) {
- X if (flag == 1) {
- X xstart = xstart - dx;
- X ystart = ystart + dy;
- X }
- X else if (flag == -2) {
- X ystart = ystart - dy;
- X xstart = xstart + dx;
- X }
- X
- X if (1 <= xstart && xstart <= nx && 1 <= ystart && ystart <= ny) {
- X u[n] = wcpcx(w3wcx(x[xstart-1],y[ystart-1],
- X *(z+(xstart-1)*ly+(ystart-1))));
- X v[n] = wcpcy(w3wcy(x[xstart-1],y[ystart-1],
- X *(z+(xstart-1)*ly+(ystart-1))));
- X n = n+1;
- X }
- X
- X }
- X plnxtv(u,v,n,init);
- X}
- SHAR_EOF
- echo "extracting pltext.c"
- sed 's/^X//' << \SHAR_EOF > pltext.c
- X/* Switches back to text mode */
- X
- X#include "plplot.h"
- X
- Xvoid pltext()
- X{
- X int dev,term,gra,level;
- X
- X glev(&level);
- X if (level < 1) fatal("Please call PLSTAR before calling PLTEXT.");
- X
- X gdev(&dev,&term,&gra);
- X if (term != 0) beepw();
- X grtext();
- X}
- SHAR_EOF
- echo "extracting plvpor.c"
- sed 's/^X//' << \SHAR_EOF > plvpor.c
- X/* Sets the edges of the viewport to the specified normalized subpage */
- X/* coordinates */
- X
- X#include "plplot.h"
- X
- Xvoid plvpor(xmin, xmax, ymin, ymax)
- Xfloat xmin, xmax, ymin, ymax;
- X{
- X float spdxmi, spdxma, spdymi, spdyma;
- X float vpdxmi, vpdxma, vpdymi, vpdyma;
- X int vppxmi, vppxma, vppymi, vppyma;
- X
- X int nx, ny, cs;
- X
- X int level;
- X
- X glev(&level);
- X if (level < 1) fatal("Please call PLSTAR before calling PLVPOR.");
- X if((xmin>=xmax)||(ymin>=ymax)||(xmin<0.)||
- X (ymin<0.)||(xmax>1.)||(ymax>1.))
- X fatal("Invalid limits in PLSVPA.");
- X
- X gsub(&nx,&ny,&cs);
- X if ((cs<=0) || (cs>(nx*ny)))
- X fatal("Please call PLADV or PLENV to go to a subpage.");
- X gspd(&spdxmi,&spdxma,&spdymi,&spdyma);
- X vpdxmi = spdxmi + (spdxma - spdxmi) * xmin;
- X vpdxma = spdxmi + (spdxma - spdxmi) * xmax;
- X vpdymi = spdymi + (spdyma - spdymi) * ymin;
- X vpdyma = spdymi + (spdyma - spdymi) * ymax;
- X svpd(vpdxmi,vpdxma,vpdymi,vpdyma);
- X
- X vppxmi = dcpcx(vpdxmi);
- X vppxma = dcpcx(vpdxma);
- X vppymi = dcpcy(vpdymi);
- X vppyma = dcpcy(vpdyma);
- X svpp(vppxmi,vppxma,vppymi,vppyma);
- X sclp(vppxmi,vppxma,vppymi,vppyma);
- X slev(2);
- X}
- SHAR_EOF
- echo "extracting plvsta.c"
- sed 's/^X//' << \SHAR_EOF > plvsta.c
- X/* Defines a "standard" viewport with seven character heights for */
- X/* the left margin and four character heights everywhere else */
- X
- X#include "plplot.h"
- X
- Xvoid plvsta()
- X{
- X float xmin, xmax, ymin, ymax;
- X float chrdef, chrht, spdxmi, spdxma, spdymi, spdyma;
- X
- X int level;
- X
- X glev(&level);
- X if (level < 1) fatal("Please call PLSTAR before calling PLVSTA.");
- X
- X gchr(&chrdef,&chrht);
- X gspd(&spdxmi,&spdxma,&spdymi,&spdyma);
- X
- X/* Find out position of subpage boundaries in millimetres, reduce by */
- X/* the desired border, and convert back into normalized subpage */
- X/* coordinates */
- X
- X xmin = dcscx(mmdcx(dcmmx(spdxmi) + 7 * chrht));
- X xmax = dcscx(mmdcx(dcmmx(spdxma) - 4 * chrht));
- X ymin = dcscy(mmdcy(dcmmy(spdymi) + 4 * chrht));
- X ymax = dcscy(mmdcy(dcmmy(spdyma) - 4 * chrht));
- X
- X plvpor(xmin,xmax,ymin,ymax);
- X}
- SHAR_EOF
- echo "extracting plw3d.c"
- sed 's/^X//' << \SHAR_EOF > plw3d.c
- X/* Set up a window for three-dimensional plotting. The data are mapped */
- X/* into a box with world coordinate size "basex" by "basey" by "height", */
- X/* with the base being symmetrically positioned about zero. Thus */
- X/* the mapping between data 3-d and world 3-d coordinates is given by: */
- X
- X/* x = xmin => wx = -0.5*basex */
- X/* x = xmax => wx = 0.5*basex */
- X/* y = ymin => wy = -0.5*basey */
- X/* y = ymax => wy = 0.5*basey */
- X/* z = zmin => wz = 0.0 */
- X/* z = zmax => wz = height */
- X
- X/* The world coordinate box is then viewed from position "alt"-"az", */
- X/* measured in degrees. For proper operation, 0 <= alt <= 90 degrees, */
- X/* but az can be any value. */
- X
- X#include "plplot.h"
- X#include <math.h>
- X
- X#define dtr 0.01745329252
- X
- Xvoid plw3d(basex,basey,height,xmin0,xmax0,ymin0,ymax0,zmin0,zmax0,alt,az)
- Xfloat basex, basey, height, xmin0, xmax0, ymin0, ymax0, zmin0, zmax0;
- Xfloat alt, az;
- X{
- X float xmin, xmax, ymin, ymax, zmin, zmax, d;
- X float cx, cy, saz, caz, salt, calt, zscale;
- X
- X int level;
- X glev(&level);
- X if (level < 3) fatal("Please set up 2-d window before calling PLW3D.");
- X if (basex <= 0.0 || basey <= 0.0 || height <= 0.0)
- X fatal("Invalid world coordinate boxsize in PLW3D.");
- X if (xmin0 == xmax0 || ymin0 == ymax0 || zmin0 == zmax0)
- X fatal("Invalid axis range in PLW3D.");
- X if (alt<0.0 || alt>90.0)
- X fatal("Altitude must be between 0 and 90 degrees in PLW3D.");
- X
- X d = 1.0e-5*(xmax0-xmin0);
- X xmax = xmax0 + d;
- X xmin = xmin0 - d;
- X d = 1.0e-5*(ymax0-ymin0);
- X ymax = ymax0 + d;
- X ymin = ymin0 - d;
- X d = 1.0e-5*(zmax0-zmin0);
- X zmax = zmax0 + d;
- X zmin = zmin0 - d;
- X cx = basex/(xmax-xmin);
- X cy = basey/(ymax-ymin);
- X zscale = height/(zmax-zmin);
- X saz = sin(dtr*az);
- X caz = cos(dtr*az);
- X salt = sin(dtr*alt);
- X calt = cos(dtr*alt);
- X
- X sdom(xmin,xmax,ymin,ymax);
- X srange(zscale,zmin,zmax);
- X sbase(basex,basey,0.5*(xmin+xmax),0.5*(ymin+ymax));
- X
- X sw3wc(cx*caz,-cy*saz,cx*saz*salt,cy*caz*salt,zscale*calt);
- X}
- X
- SHAR_EOF
- echo "extracting plwind.c"
- sed 's/^X//' << \SHAR_EOF > plwind.c
- X#include "plplot.h"
- X
- Xvoid plwind(xmin,xmax,ymin,ymax)
- Xfloat xmin, xmax, ymin, ymax;
- X{
- X int vppxmi, vppxma, vppymi, vppyma;
- X float dx, dy;
- X float vpwxmi, vpwxma, vpwymi, vpwyma;
- X float vpxmi, vpxma, vpymi, vpyma;
- X float wpxscl, wpxoff, wpyscl, wpyoff;
- X float wmxscl, wmxoff, wmyscl, wmyoff;
- X
- X int level;
- X
- X glev(&level);
- X if (level<2) fatal("Please set up viewport before calling PLWIND.");
- X
- X gvpp(&vppxmi,&vppxma,&vppymi,&vppyma);
- X gvpd(&vpxmi,&vpxma,&vpymi,&vpyma);
- X
- X dx = (xmax-xmin) * 1.0e-5;
- X dy = (ymax-ymin) * 1.0e-5;
- X
- X if ((xmin == xmax) || (ymin == ymax))
- X fatal("Invalid window limits in PLWIND.");
- X
- X/* The true plot window is made slightly larger than requested so that */
- X/* the end limits will be on the graph */
- X
- X svpw(xmin-dx,xmax+dx,ymin-dy,ymax+dy);
- X gvpw(&vpwxmi,&vpwxma,&vpwymi,&vpwyma);
- X
- X/* Compute the scaling between coordinate systems */
- X
- X dx = vpwxma - vpwxmi;
- X dy = vpwyma - vpwymi;
- X
- X wpxscl = (vppxma - vppxmi) / dx;
- X wpxoff = (xmax * vppxmi - xmin * vppxma) / dx;
- X wpyscl = (vppyma - vppymi) / dy;
- X wpyoff = (ymax * vppymi - ymin * vppyma) / dy;
- X swp(wpxscl,wpxoff,wpyscl,wpyoff);
- X
- X vpxmi = dcmmx(vpxmi);
- X vpxma = dcmmx(vpxma);
- X vpymi = dcmmy(vpymi);
- X vpyma = dcmmy(vpyma);
- X wmxscl = (vpxma - vpxmi) / dx;
- X wmxoff = (xmax * vpxmi - xmin * vpxma) / dx;
- X wmyscl = (vpyma - vpymi) / dy;
- X wmyoff = (ymax * vpymi - ymin * vpyma) / dy;
- X swm(wmxscl,wmxoff,wmyscl,wmyoff);
- X
- X slev(3);
- X}SHAR_EOF
- echo "extracting plxtik.c"
- sed 's/^X//' << \SHAR_EOF > plxtik.c
- X#include "plplot.h"
- X
- Xvoid plxtik(x,y,below,above)
- Xint x, y, below, above;
- X{
- X draphy(x,y);
- X if (below != 0) draphy(x,y-below);
- X if (above != 0) draphy(x,y+above);
- X draphy(x,y);
- X}
- SHAR_EOF
- echo "extracting plxybx.c"
- sed 's/^X//' << \SHAR_EOF > plxybx.c
- X/* This draws a sloping line from (wx1,wy1) to (wx2,wy2) */
- X/* which represents an axis of a 3-d graph with data values from */
- X/* "vmin" to "vmax". Depending on "opt", vertical ticks and/or */
- X/* subticks are placed on the line at major tick interval "tick" */
- X/* with "nsub" subticks between major ticks. If "tick" and/or */
- X/* "nsub" is zero, automatic tick positions are computed */
- X
- X/* B: Draw box boundary */
- X/* I: Inverts tick marks (i.e. drawn downwards) */
- X/* L: Logarithmic axes, major ticks at decades, minor ticks at units */
- X/* N: Write numeric label */
- X/* T: Draw major tick marks */
- X/* S: Draw minor tick marks */
- X/* U: Write label on line */
- X
- X#include "plplot.h"
- X#include <stdio.h>
- X#include <math.h>
- X
- X#define betw(c,a,b) ((a <= c && c <= b) || (b <= c && c <= a))
- X
- Xstatic float xlog[8] =
- X {0.301030,0.477121,0.602060,0.698970,0.778151,0.845098,0.903090,0.954243};
- X
- Xvoid plxybx(opt,label,wx1,wy1,wx2,wy2,vmin,vmax,tick,nsub,nolast)
- Xchar *opt, *label;
- Xfloat wx1, wy1, wx2, wy2, vmin, vmax, tick;
- Xint nsub, nolast;
- X{
- X char string[40];
- X int lb,li,ll,ln,ls,lt,lu;
- X int major, minor, mode, prec;
- X int i, i1, i2, i3, i4;
- X int nsub1;
- X float xpmm, ypmm, defmaj, defmin, htmaj, htmin, tick1;
- X float pos, tn, tp, temp;
- X float dwx, dwy, lambda;
- X
- X dwx = wx2 - wx1;
- X dwy = wy2 - wy1;
- X
- X/* Tick and subtick sizes in device coords */
- X
- X gpixmm(&xpmm,&ypmm);
- X gmaj(&defmaj,&htmaj);
- X gmin(&defmin,&htmin);
- X
- X major=max(round(htmaj*ypmm),1);
- X minor=max(round(htmin*ypmm),1);
- X
- X tick1=tick;
- X nsub1=nsub;
- X
- X lb=strpos(opt,'B')!=-1||strpos(opt,'b')!=-1;
- X li=strpos(opt,'I')!=-1||strpos(opt,'i')!=-1;
- X ll=strpos(opt,'L')!=-1||strpos(opt,'l')!=-1;
- X ln=strpos(opt,'N')!=-1||strpos(opt,'n')!=-1;
- X ls=strpos(opt,'S')!=-1||strpos(opt,'s')!=-1;
- X lt=strpos(opt,'T')!=-1||strpos(opt,'t')!=-1;
- X lu=strpos(opt,'U')!=-1||strpos(opt,'u')!=-1;
- X
- X if (lu) plxytx(wx1,wy1,wx2,wy2,3.2,0.5,0.5,label);
- X if (!lb) return;
- X
- X if (ll) tick1 = 1.0;
- X if (lt) pldtik(vmin,vmax,&tick1,&nsub1,&mode,&prec);
- X
- X if (li) {
- X i1 = minor;
- X i2 = 0;
- X i3 = major;
- X i4 = 0;
- X }
- X else {
- X i1 = 0;
- X i2 = minor;
- X i3 = 0;
- X i4 = major;
- X }
- X
- X/* Draw the line */
- X
- X movwor(wx1,wy1);
- X if (lt) {
- X tp=tick1*floor(vmin/tick1);
- Xlab2:
- X tn=tp+tick1;
- X if (ls) {
- X if (ll) {
- X for (i=0; i<=7; i++) {
- X temp=tp+xlog[i];
- X if (betw(temp,vmin,vmax)) {
- X lambda = (temp-vmin)/(vmax-vmin);
- X plxtik(wcpcx(wx1+lambda*dwx),wcpcy(wy1+lambda*dwy),i1,i2);
- X }
- X }
- X }
- X else {
- X for(i=1; i <= nsub1-1; i++) {
- X temp=tp+i*(tn-tp)/nsub1;
- X if (betw(temp,vmin,vmax)) {
- X lambda = (temp-vmin)/(vmax-vmin);
- X plxtik(wcpcx(wx1+lambda*dwx),wcpcy(wy1+lambda*dwy),i1,i2);
- X }
- X }
- X }
- X }
- X temp=tn;
- X if (betw(temp,vmin,vmax)) {
- X lambda = (temp-vmin)/(vmax-vmin);
- X plxtik(wcpcx(wx1+lambda*dwx),wcpcy(wy1+lambda*dwy),i3,i4);
- X tp=tn;
- X goto lab2;
- X }
- X }
- X
- X drawor(wx2,wy2);
- X
- X/* Label the line */
- X
- X if (ln && lt) {
- X tp=tick1*floor(vmin/tick1);
- Xlab82:
- X tn=tp+tick1;
- X if (nolast && !betw(tn+tick1,vmin,vmax)) return;
- X if (betw(tn,vmin,vmax)) {
- X if (!ll)
- X plform(tn,mode,prec,string);
- X else
- X sprintf(string,"10\\u%-d",round(tn));
- X pos=(tn-vmin)/(vmax-vmin);
- X if (ln) plxytx(wx1,wy1,wx2,wy2,1.5,pos,0.5,string);
- X tp=tn;
- X goto lab82;
- X }
- X }
- X}
- SHAR_EOF
- echo "extracting plxytx.c"
- sed 's/^X//' << \SHAR_EOF > plxytx.c
- X/* Prints out text along a sloping axis joining world coordinates */
- X/* (wx1,wy1) to (wx2,wy2). Parameters are as for plmtext */
- X
- X#include "plplot.h"
- X#include <math.h>
- X
- Xvoid plxytx(wx1,wy1,wx2,wy2,disp,pos,just,text)
- Xfloat wx1,wy1,wx2,wy2,disp,pos,just;
- Xchar *text;
- X{
- X int refx, refy;
- X float shift, cc, ss, def, ht;
- X float xform[4], diag;
- X float xscl, xoff, yscl, yoff, wx, wy;
- X
- X gchr(&def,&ht);
- X gwm(&xscl,&xoff,&yscl,&yoff);
- X cc = xscl * (wx2-wx1);
- X ss = yscl * (wy2-wy1);
- X diag = sqrt(cc*cc + ss*ss);
- X cc = cc/diag;
- X ss = ss/diag;
- X
- X xform[0] = cc;
- X xform[1] = 0.0;
- X xform[2] = ss;
- X xform[3] = 1.0;
- X
- X shift = 0.0;
- X if (just != 0.0) shift = plstrl(text) * just;
- X wx = wx1 + pos * (wx2 - wx1);
- X wy = wy1 + pos * (wy2 - wy1);
- X
- X refx = mmpcx(wcmmx(wx) - shift * cc);
- X refy = mmpcy(wcmmy(wy) - shift * ss - disp * ht);
- X plstr(0,xform,refx,refy,text);
- X}
- SHAR_EOF
- echo "extracting plytik.c"
- sed 's/^X//' << \SHAR_EOF > plytik.c
- X#include "plplot.h"
- X
- Xvoid plytik(x,y,left,right)
- Xint x, y, left, right;
- X{
- X draphy(x,y);
- X if (left != 0) draphy(x-left,y);
- X if (right != 0) draphy(x+right,y);
- X draphy(x,y);
- X}
- SHAR_EOF
- echo "extracting plzbx.c"
- sed 's/^X//' << \SHAR_EOF > plzbx.c
- X/* This draws a vertical line from (wx,wy1) to (wx,wy2) */
- X/* which represents the vertical axis of a 3-d graph with data */
- X/* values from "vmin" to "vmax". Depending on "opt", ticks and/or*/
- X/* subticks are placed on the line at major tick interval "tick" */
- X/* with "nsub" subticks between major ticks. If "tick" and/or */
- X/* "nsub" is zero, automatic tick positions are computed */
- X
- X/* B: Draws left-hand axis*/
- X/* C: Draws right-hand axis*/
- X/* I: Inverts tick marks (i.e. drawn to the left) */
- X/* L: Logarithmic axes, major ticks at decades, minor ticks at units*/
- X/* M: Write numeric label on right axis*/
- X/* N: Write numeric label on left axis*/
- X/* S: Draw minor tick marks */
- X/* T: Draw major tick marks */
- X/* U: Writes left-hand label*/
- X/* V: Writes right-hand label*/
- X
- X#include "plplot.h"
- X#include <stdio.h>
- X#include <math.h>
- X
- X#define betw(c,a,b) ((a <= c && c <= b) || (b <= c && c <= a))
- X
- Xstatic float xlog[8] =
- X {0.301030,0.477121,0.602060,0.698970,0.778151,0.845098,
- X 0.903090,0.954243};
- X
- Xvoid plzbx(opt,label,right,dx,dy,wx,wy1,wy2,vmin,vmax,tick,nsub)
- Xchar *opt, *label;
- Xfloat dx, dy, wx, wy1, wy2, vmin, vmax, tick;
- Xint nsub, right;
- X{
- X char string[40];
- X int lb,lc,li,ll,lm,ln,ls,lt,lu,lv;
- X int i, mode, prec;
- X int nsub1;
- X float xpmm, ypmm, defmaj, defmin, tick1;
- X float pos, tn, tp, temp;
- X float dwy, lambda, diag, major, minor, xmajor, xminor;
- X float ymajor, yminor, dxm, dym, xscl, xoff, yscl, yoff;
- X
- X dwy = wy2 - wy1;
- X
- X/* Tick and subtick sizes in device coords */
- X
- X gpixmm(&xpmm,&ypmm);
- X gmaj(&defmaj,&major);
- X gmin(&defmin,&minor);
- X
- X tick1=tick;
- X nsub1=nsub;
- X
- X lb=strpos(opt,'B') != -1 || strpos(opt,'b') != -1;
- X lc=strpos(opt,'C') != -1 || strpos(opt,'c') != -1;
- X li=strpos(opt,'I') != -1 || strpos(opt,'i') != -1;
- X ll=strpos(opt,'L') != -1 || strpos(opt,'l') != -1;
- X lm=strpos(opt,'M') != -1 || strpos(opt,'m') != -1;
- X ln=strpos(opt,'N') != -1 || strpos(opt,'n') != -1;
- X ls=strpos(opt,'S') != -1 || strpos(opt,'s') != -1;
- X lt=strpos(opt,'T') != -1 || strpos(opt,'t') != -1;
- X lu=strpos(opt,'U') != -1 || strpos(opt,'u') != -1;
- X lv=strpos(opt,'V') != -1 || strpos(opt,'v') != -1;
- X
- X if (lu && !right) plztx("h",dx,dy,wx,wy1,wy2,5.0,0.5,0.5,label);
- X if (lv && right) plztx("h",dx,dy,wx,wy1,wy2,-5.0,0.5,0.5,label);
- X
- X if (right && !lc) return;
- X if (!right && !lb) return;
- X
- X if (ll) tick1 = 1.0;
- X if (lt) pldtik(vmin,vmax,&tick1,&nsub1,&mode,&prec);
- X
- X if ( (li && !right) || (!li && right) ) {
- X minor = -minor;
- X major = -major;
- X }
- X
- X gwm(&xscl,&xoff,&yscl,&yoff);
- X dxm = dx * xscl;
- X dym = dy * yscl;
- X diag = sqrt(dxm*dxm + dym*dym);
- X
- X xminor = minor * dxm/diag;
- X xmajor = major * dxm/diag;
- X yminor = minor * dym/diag;
- X ymajor = major * dym/diag;
- X
- X/* Draw the line */
- X
- X movwor(wx,wy1);
- X if (lt) {
- X tp=tick1*floor(vmin/tick1);
- Xlab2:
- X tn=tp+tick1;
- X if (ls) {
- X if (ll) {
- X for (i=0; i <= 7; i++) {
- X temp=tp+xlog[i];
- X if (betw(temp,vmin,vmax)) {
- X lambda = (temp-vmin)/(vmax-vmin);
- X plstik(wcmmx(wx),wcmmy(wy1+lambda*dwy),xminor,yminor);
- X }
- X }
- X }
- X else {
- X for (i=1; i<= nsub1-1; i++) {
- X temp=tp+i*(tn-tp)/nsub1;
- X if (betw(temp,vmin,vmax)) {
- X lambda = (temp-vmin)/(vmax-vmin);
- X plstik(wcmmx(wx),wcmmy(wy1+lambda*dwy),xminor,yminor);
- X }
- X }
- X }
- X }
- X temp=tn;
- X if (betw(temp,vmin,vmax)) {
- X lambda = (temp-vmin)/(vmax-vmin);
- X plstik(wcmmx(wx),wcmmy(wy1+lambda*dwy),xmajor,ymajor);
- X tp=tn;
- X goto lab2;
- X }
- X }
- X
- X drawor(wx,wy2);
- X
- X/* Label the line */
- X
- X if (ln && lt) {
- X tp=tick1*floor(vmin/tick1);
- Xlab82:
- X tn=tp+tick1;
- X if (betw(tn,vmin,vmax)) {
- X if (!ll)
- X plform(tn,mode,prec,string);
- X else
- X sprintf(string,"10\\u%d",round(tn));
- X pos=(tn-vmin)/(vmax-vmin);
- X if (ln && !right) plztx("v",dx,dy,wx,wy1,wy2,0.5,pos,1.0,string);
- X if (lm && right) plztx("v",dx,dy,wx,wy1,wy2,-0.5,pos,0.0,string);
- X tp=tn;
- X goto lab82;
- X }
- X }
- X}
- SHAR_EOF
- echo "extracting plztx.c"
- sed 's/^X//' << \SHAR_EOF > plztx.c
- X/* Prints out text along a vertical axis for a 3d plot joining */
- X/* world coordinates (wx,wy1) to (wx,wy2). */
- X
- X#include "plplot.h"
- X#include <math.h>
- X
- Xvoid plztx(opt,dx,dy,wx,wy1,wy2,disp,pos,just,text)
- Xfloat dx,dy,wx,wy1,wy2,disp,pos,just;
- Xchar *opt, *text;
- X{
- X int refx, refy;
- X int vert;
- X float shift, cc, ss, def, ht;
- X float xform[4], diag;
- X float xscl, xoff, yscl, yoff, wy;
- X
- X gchr(&def,&ht);
- X gwm(&xscl,&xoff,&yscl,&yoff);
- X cc = xscl * dx;
- X ss = yscl * dy;
- X diag = sqrt(cc*cc + ss*ss);
- X cc = cc/diag;
- X ss = ss/diag;
- X gmp(&xscl,&xoff,&yscl,&yoff);
- X
- X shift = 0.0;
- X if (just != 0.0) shift = plstrl(text) * just;
- X wy = wy1 + pos * (wy2 - wy1);
- X
- X if (strpos(opt,'V') != -1 || strpos(opt,'v') != -1) {
- X vert = 0;
- X refx = mmpcx(wcmmx(wx) - (disp * ht + shift) * cc);
- X refy = mmpcy(wcmmy(wy) - (disp * ht + shift) * ss);
- X }
- X else if (strpos(opt,'H') != -1 || strpos(opt,'h') != -1) {
- X vert = 1;
- X refy = wcpcy(wy) - yscl*(disp*ht*ss+shift);
- X refx = mmpcx(wcmmx(wx) - disp*ht*cc);
- X }
- X if (vert) {
- X xform[0] = 0.0;
- X xform[1] = -cc;
- X xform[2] = 1.0;
- X xform[3] = -ss;
- X }
- X else {
- X xform[0] = cc;
- X xform[1] = 0.0;
- X xform[2] = ss;
- X xform[3] = 1.0;
- X }
- X plstr(0,xform,refx,refy,text);
- X}
- SHAR_EOF
- echo "extracting round.c"
- sed 's/^X//' << \SHAR_EOF > round.c
- X/* round rounds a floating point value to an integer value. */
- X
- X#include "plplot.h"
- X#include <math.h>
- X
- Xint round(flt)
- Xfloat flt;
- X{
- X double mant, frac;
- X
- X frac = modf(flt,&mant);
- X if( fabs(frac) < .5 )
- X return((int)mant);
- X else if (frac > 0)
- X return((int)(++mant));
- X else
- X return((int)(--mant));
- X}
- SHAR_EOF
- echo "extracting scratch"
- sed 's/^X//' << \SHAR_EOF > scratch
- X; I had problems with the LMKFILE when I wanted to remake the library
- X; from scratch. It barfed if I tried to pass to many source files to
- X; the compiler. Normally you shouldn't need to execute this script.
- X; If you've only changed a few routines use LMK instead. But in
- X; case of disaster try this. After you start it, take a break and
- X; go get a pizza. No, wait, sorry, that was a flashback to my IBM
- X; PC days. Pop open a new window and do something else :-):-)
- Xdelete lib/plplot.lib ; delete old library
- Xcopy nil: lib/plplot.lib ; create an empty new one
- Xtouch src/plabv.c src/pladv.c src/plbeg.c src/plbin.c src/plbox.c
- Xtouch src/plccal.c src/plclr.c src/plcntr.c src/plcol.c src/plcont.c
- Xtouch src/plcvec.c src/pldeco.c src/pldtik.c src/plend.c src/plenv.c
- Xlmk
- Xtouch src/plerrx.c src/plerry.c src/plerx1.c src/plery1.c src/plfont.c
- Xtouch src/plform.c src/plgra.c src/plgspa.c src/plhist.c src/plhrsh.c
- Xtouch src/pljoin.c src/pllab.c src/pllclp.c src/plline.c src/plmtex.c
- Xlmk
- Xtouch src/plnxtv.c src/plpoi1.c src/plpoin.c src/plptex.c src/plr135.c
- Xtouch src/plr45.c src/plschr.c src/plsmaj.c src/plsmin.c src/plssym.c
- Xtouch src/plstar.c src/plstik.c src/plstr.c src/plstrl.c src/plstyl.c
- Xlmk
- Xtouch src/plsvpa.c src/plsym.c src/plsym1.c src/pltext.c src/plvpor.c
- Xtouch src/plvsta.c src/plwind.c src/plxtik.c src/plxybx.c src/plxytx.c
- Xtouch src/plytik.c src/plzbx.c src/plztx.c src/pl3cut.c src/plbox3.c
- Xlmk
- Xtouch src/plgrid3.c src/plot3d.c src/plside3.c src/plt3zz.c src/plw3d.c
- Xtouch src/define.c src/fatal.c src/fcnvrt.c src/genlin.c src/global.c
- Xtouch src/icnvrt.c src/movphy.c src/movwor.c src/round.c src/setphy.c
- Xlmk
- Xtouch src/setpxl.c src/setsub.c src/stindex.c src/strpos.c src/xform.c
- Xtouch src/impress.c src/laserjetii.c src/tektronix.c src/Amiga.c
- Xtouch src/font01.c src/font02.c src/font03.c src/font04.c src/font05.c
- Xlmk
- Xtouch src/font06.c src/font07.c src/font08.c src/font09.c src/font10.c
- Xtouch src/font11.c
- Xlmk
- SHAR_EOF
- echo "extracting setphy.c"
- sed 's/^X//' << \SHAR_EOF > setphy.c
- X/* Sets up physical limits of plotting device and the mapping between */
- X/* normalized device coordinates and physical coordinates */
- X
- X#include "plplot.h"
- X
- Xvoid setphy(xmin,xmax,ymin,ymax)
- Xint xmin,xmax,ymin,ymax;
- X{
- X float xpmm, ypmm, mpxscl, mpyscl;
- X
- X sphy(xmin,xmax,ymin,ymax);
- X sdp((double)(xmax-xmin),(double)(xmin),(double)(ymax-ymin),
- X (double)(ymin));
- X
- X gpixmm(&xpmm,&ypmm);
- X mpxscl = xpmm;
- X if (xmax <= xmin) mpxscl = -xpmm;
- X mpyscl = ypmm;
- X if (ymax <= ymin) mpyscl = -ypmm;
- X smp(mpxscl,(double)(xmin), mpyscl,(double)(ymin));
- X}
- X
- SHAR_EOF
- echo "extracting setpxl.c"
- sed 's/^X//' << \SHAR_EOF > setpxl.c
- X/* Sets up pixel size from the number of pixels/mm in each direction */
- X
- X#include "plplot.h"
- X#include "declare.h"
- X
- Xvoid setpxl(xpmm0,ypmm0)
- Xfloat xpmm0,ypmm0;
- X{
- X xpmm = xpmm0;
- X ypmm = ypmm0;
- X umx = 1000.0/xpmm;
- X umy = 1000.0/ypmm;
- X}
- SHAR_EOF
- echo "extracting setsub.c"
- sed 's/^X//' << \SHAR_EOF > setsub.c
- X/* Sets up the subpage boundaries according to the current subpage */
- X/* selected */
- X
- X#include "plplot.h"
- X
- Xvoid setsub()
- X{
- X int ix, iy;
- X int nsubx, nsuby, cursub;
- X float spdxmi, spdxma, spdymi, spdyma;
- X int sppxmi, sppxma, sppymi, sppyma;
- X
- X gsub(&nsubx,&nsuby,&cursub);
- X ix = (cursub-1)%nsubx;
- X iy = nsuby - (cursub-1)/nsubx;
- X
- X spdxmi = (float)(ix)/(float)(nsubx);
- X spdxma = (float)(ix+1)/(float)(nsubx);
- X spdymi = (float)(iy-1)/(float)(nsuby);
- X spdyma = (float)(iy)/(float)(nsuby);
- X sspd(spdxmi,spdxma,spdymi,spdyma);
- X
- X sppxmi = dcpcx(spdxmi);
- X sppxma = dcpcx(spdxma);
- X sppymi = dcpcy(spdymi);
- X sppyma = dcpcy(spdyma);
- X sspp(sppxmi,sppxma,sppymi,sppyma);
- X
- X sclp(sppxmi,sppxma,sppymi,sppyma);
- X
- X}
- SHAR_EOF
- echo "extracting stindex.c"
- sed 's/^X//' << \SHAR_EOF > stindex.c
- X#include "plplot.h"
- X
- Xint stindex(str1,str2)
- Xchar *str1,*str2;
- X{
- X int base;
- X int str1ind;
- X int str2ind;
- X
- X for(base=0; *(str1+base)!='\0'; base++) {
- X for(str1ind=base, str2ind=0; *(str2+str2ind)!='\0' &&
- X *(str2+str2ind) == *(str1+str1ind); str1ind++, str2ind++)
- X ; /* no body */
- X
- X if(*(str2+str2ind) == '\0')
- X return(base);
- X }
- X return(-1); /* search failed */
- X}
- SHAR_EOF
- echo "extracting strpos.c"
- sed 's/^X//' << \SHAR_EOF > strpos.c
- X/* Searches string str for first occurence of character chr. If found */
- X/* the position of the character in the string is returned (the first */
- X/* character has position 0). If the character is not found a -1 is */
- X/* returned. */
- X
- X#include "plplot.h"
- X#include <stdio.h> /* Needed to define NULL */
- X#include <string.h>
- X
- Xint strpos(str,chr)
- Xchar *str,chr;
- X{
- X char *temp;
- X
- X if ( (temp = strchr(str,chr)) != NULL)
- X return(temp - str);
- X else
- X return(-1);
- X}
- SHAR_EOF
- echo "extracting tektronix.c"
- sed 's/^X//' << \SHAR_EOF > tektronix.c
- X/* This file contains the tektronix dependent routines for use with plplot. */
- X
- X/* Define graphics control characters. */
- X#define BS 8
- X#define HT 9
- X#define LF 10
- X#define VT 11
- X#define FF 12
- X#define CR 13
- X#define CAN 24
- X#define EM 25
- X#define ESC 27
- X#define FS 28
- X#define GS 29
- X#define US 31
- X
- X#include <stdio.h>
- X#include "plplot.h"
- X
- Xstatic FILE *OutFile;
- Xstatic int FirstClear=1;
- X
- X/* Open file. */
- Xvoid tekini()
- X{
- X char FileName[80];
- X
- X printf("Enter file to receive tektronix graphics commands. ");
- X scanf("%s",FileName);
- X
- X if ((OutFile = fopen(FileName,"w")) == NULL) {
- X printf("Error opening %s \n",FileName);
- X exit(1);
- X }
- X}
- X
- X/* Sets the tektronix to text mode */
- Xvoid tektex()
- X{
- X fprintf(OutFile,"%c",US);
- X}
- X
- X/* Sets the tektronix to graphics mode */
- Xvoid tekgra()
- X{
- X /* Nothing has to be done here */
- X}
- X
- X/* Clears the tektronix screen */
- Xvoid tekclr()
- X{
- X if(FirstClear)
- X FirstClear = 0;
- X else
- X fprintf(OutFile,"%c%c",ESC,FF);
- X}
- X
- X/* Change color */
- Xvoid tekcol(colour)
- Xint colour;
- X{
- X}
- X
- X/* Draws a line in the current colour from (x1,y1) to (x2,y2) */
- Xvoid teklin(x1,y1,x2,y2)
- Xint x1,y1,x2,y2;
- X{
- X int hy,ly,hx,lx;
- X
- X fprintf(OutFile,"%c",GS);
- X hy = y1/32 + 32;
- X ly = y1 - (y1/32)*32 + 96;
- X hx = x1/32 + 32;
- X lx = x1 - (x1/32)*32 + 64;
- X fprintf(OutFile,"%c%c%c%c",hy,ly,hx,lx);
- X hy = y2/32 + 32;
- X ly = y2 - (y2/32)*32 + 96;
- X hx = x2/32 + 32;
- X lx = x2 - (x2/32)*32 + 64;
- X fprintf(OutFile,"%c%c%c%c",hy,ly,hx,lx);
- X}
- X
- X/* Close file */
- Xvoid tektid()
- X{
- X fclose(OutFile);
- X}
- X
- SHAR_EOF
- echo "extracting xform.c"
- sed 's/^X//' << \SHAR_EOF > xform.c
- X#include "plplot.h"
- X
- Xvoid xform(x,y,tx,ty)
- Xfloat x, y, *tx, *ty;
- X{
- X extern float tr[];
- X
- X *tx = tr[0]*x + tr[1]*y + tr[2];
- X *ty = tr[3]*x + tr[4]*y + tr[5];
- X}
- X
- SHAR_EOF
- echo "End of archive 7 (of 7)"
- # if you want to concatenate archives, remove anything after this line
- exit
-